home *** CD-ROM | disk | FTP | other *** search
/ Cracking 2 / Cracking II..iso / Texty / crackme / SiFLyiNG_6.txt < prev    next >
Encoding:
Text File  |  1999-07-27  |  6.2 KB  |  166 lines

  1.  
  2.         SiFLyiNG
  3.                 Tutorial #6
  4.  
  5. ____________________________________________________________________________
  6.  
  7. Target          : CupOfCoffee Crackme 2 (giger_crackme.zip)
  8.                 d/l on EB site at http://crackmes.cjb.net
  9. Protection Type : Code, VB : code sniffing and patch
  10. Level           : the author says it's easy
  11. Tools needed    : SoftIce 3.xx
  12.                   Windasm
  13.                   An hex editor (Hiew, hewWorkshop, Hedit...)
  14.                   Some basis of VB cracking and patching
  15.  
  16. ____________________________________________________________________________
  17.  
  18. Before beginning...
  19.  
  20.         First I advise you to read my 3rd Tut on CupOfCoffee crackme 1. The
  21. method to find the serial is exactly the same. Here i'll summarize but you
  22. can find my tut on EB site. We'll then study different ways to crack the
  23. protection scheme (a classic comparison).
  24.         Time is money... so let's start !
  25.  
  26. ____________________________________________________________________________
  27.  
  28. The essay...
  29.  
  30.         1. Finding the correct serial
  31.  
  32.         Ok, i'll won't do big explanations. If you wanna know more, read my
  33. 3rd tut. Besides the serial hasn't change from the first crackme to this one!
  34.         So, let's bpx on __vbaStrCmp. Exit SoftIce. Enter any serial, press
  35. the check button and you're to SoftIce. There press F11 to return from the
  36. caller and you will see that line.
  37.         
  38. :0052168D Call [MSVBVM50!__vbaStrCmp]
  39.  
  40.         It's the call to the comparison function. You must know that this
  41. compare the two last string pushed on the stack. So we need to know what the
  42. last pushed strings are. One is certainly our fake code and the other the
  43. good code. And these strings are in Wide Characters, ie '123456' becomes
  44. '1.2.3.4.5.6.' where '.' represents the Null char. So trace up a bit in the
  45. display of the code and you'll see up to the call :
  46.  
  47. :00521684 Mov ECX, [EBP-18]
  48. :00521687 Push ECX
  49. :00521688 Push 00450560               ; very interesting :)
  50. :0052168D Call [MSVBVM50!__vbaStrCmp] ; call to the comparison function
  51.  
  52. so you make a breakpoint on the line at adress 521687 : either you double
  53. click on it, or you make 'BPX 521687' and you should see the line in blue.
  54. Return to your crackme and press 'Check' another time. Boom, you should
  55. come back in Softice and see that :
  56.  
  57. 'Break due to 'XXXX:00521687' or something like that. And you see the previous
  58. code:
  59.  
  60. :00521687 Push ECX
  61.  
  62.         'd ECX' and you see your code
  63.  
  64. :00521688 Push 00450560
  65.  
  66.         'd 00450560' and you see
  67.  
  68. 2E 00 2E 00 2E 00 2E 00 - 2E 00 2E 00 2E 00 2E 00   ................
  69. 2E 00 2E 00 00 00 00 00 - 24 00 00 00 49 00 6E 00   ........$...I.n.
  70.  
  71. What's that you ask me ??? There nothing !!! No, look attentively the hexa
  72. display. Do you see only 00 00 00 ??? No ! You see 2E 00 2E ... and if you
  73. make a '? 2E' you should see :
  74.  
  75.         0000002E  0000000046  "."
  76.  
  77. so you rapidly deduce that 2Eh is the ASCII code of the point character !
  78. Thus, our code is composed by 10 "." ; yes, really! Count them if you don't
  79. believe me. This protection is certainly the reason why the author of the
  80. crackme told it was 'tricky but easy'. You have to open your eyes to see
  81. the code, and it's not so easy ... But we found it !
  82.  
  83.         We can now go to the second part of the crackme...
  84.  
  85.         2. The patch
  86.  
  87. There are different ways to patch the giger_crackme. Here is the important
  88. code for the serial check routine:
  89.  
  90. :00521684 Mov ECX, [EBP-18]
  91. :00521687 Push ECX                    ; push the entered serial
  92. :00521688 Push 00450560               ; push the good serial
  93. :0052168D Call [MSVBVM50!__vbaStrCmp] ; call to the comparison function
  94. :00521693 Mov ESI, EAX ; returns 0 if good serial, FFFF FFFF if bad serial
  95. :00521695 Lea ECX, [EBP-18]
  96. :00521698 Neg ESI
  97. :0052169A Sbb ESI          
  98. :0052169E Neg ESI
  99. :0052169E Neg ESI   
  100. :005216A0 Call [MSVBVM50!__vbaFreeStr]
  101. :005216A6 Lea ECX, [EBP-1C]
  102. :005216A9 Call [MSVBVM50!__vbaFreeObj]
  103. :005216AF Cmp SI, DI  ; DI=0
  104. :005216B2 Jz 00521722 ; JZ to Good Cracker and display the new form
  105.  
  106. ...otherwise it displays a Message Box with 'Incorrect password' with a call
  107. rtcMsgBox. So SI must be equal to DI to jump to the good cracker routine and
  108. we know that DI = 0 so SI must be equal to 0 to jump! The first way would be
  109. to force ESI to 0. Instead of Neg ESI, we could put Xor ESI, ESI, which means
  110. that we have to change:
  111.  
  112. :0052169E  F7DE  Neg ESI to
  113.  
  114.         :0052169E  33F6  Xor ESI, ESI
  115.         
  116. But there are others solutions... of course you can patch the jz Good Cracker
  117. and replace it by a Jump Good Cracker, which would always jump. You can also
  118. replace the comparison between SI and DI by a comparison between DI and DI
  119. because DI is always equal to DI :)
  120.  
  121. :005216AF  663BF7  Cmp SI, DI    => :005216AF  663BFF  Cmp DI, DI
  122.  
  123. We know too that before the call to the VB strings comparison function,
  124. the good code and the entered code had been pushed on the stack, so that the
  125. call would compare them. But if you push the entered code instead of the good
  126. code, the call would compare the both same code, and would return 0 to say
  127. they are equal ( of course because they are the same )
  128.  
  129. So could change :
  130.  
  131. :521687 51         Push ECX
  132. :521688 6860054500 Push 00450560
  133.  
  134. to:
  135.  
  136. : 51 Push ECX
  137. : 51 Push ECX
  138. : 90 Nop
  139. : 90 Nop
  140. : 90 Nop
  141. : 90 Nop
  142.  
  143. Try it ! it functions and the winner form will be displayed !
  144.  
  145. Ok i believe they are others ways to patch this crackme, but i think i have
  146. found enough for the moment. So the crackme can now be patched to admit
  147. any serial.
  148.  
  149. ____________________________________________________________________________
  150.  
  151. The end...
  152.  
  153.         Voila, another crackme cracked by two ways this time. Just note that
  154. lots of VB progs (crackmes and commercial soft) have the same protection
  155. scheme (if we can call that a protection scheme because it's a simple
  156. comparison between the entered serial and the good serial).
  157.         I hope it was understandable. But if something was wrong or not
  158. cleared just mail me.
  159.  
  160.         SiFLyiNG
  161.                 siflying@ifrance.com
  162.  
  163.         Greetz : Eternal Bliss, Acid Burn, Carpathia, Lucifer48, Skymarshall
  164.                 and the others i've forgotten.
  165.  
  166.